package com.zhb.scanner

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log

/**
 * Created by HongboZhao on 2020/12/22.
 */
class ScanBroadcastReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        if (intent != null) {
            val barcode: String? = when (intent.action) {
                NS5 -> intent.extras?.getString(NS5_DATA)
                DT50 -> intent.extras?.getString(DT50_DATA)
                else -> null
            }
            Log.d("Scanner", "Scan bar Code is ${barcode.toString()}")
            if (barcode != null && barcode.isNotEmpty()) {
                Scanner.instance.get().value = barcode
            }
        }
    }
}